<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    const app = Vue.createApp({//application 创建一个Vue应用
        data() {
            return {
                message: 'bilibili',
                price: 10,
                count: 5,
            }
        },
        //计算属性的特性，当计算属性依赖的内容发生变化时，才会重新执行计算
        computed: {
            total() {
                return this.count * this.price
                // return Date.now()
            }
        },
        methods: {
            handleitemclick() {
                this.message = this.message == 'hello world!' ? '你好世界' : 'hello world!'
            },
            // 只要页面重新渲染就会执行方法
            getTime() {
                return Date.now()
            },
            addcount() {
                this.count++;
            }
        },
        // <h2>{{getTime()}}</h2>
        template: `
            <h2>{{message}}</h2>
            <h2>{{total}}</h2>
            <button @click="addcount()">+</button>
        `
    })
    const vm = app.mount("#app")//挂载这个Vue应用
</script>

</html>